﻿/* 图表无数据提示 */
/* $chart：图表所在的jquery dom对象 */
function chartNoDataHint($chart) {
    var hintId = $chart.attr('id') + '_hint';
    var noDataHint = '<div class="noDataHint_n" id="'+ hintId +'"></div>';
    //判断是否已添加提示dom
    if($('#' + hintId).length == 0){//未添加
        $chart.after($(noDataHint));
    }
    //获取dom的高宽
    var width = $chart.outerWidth();
    var height = $chart.outerHeight();
    $('#' + hintId).css({
        'marginTop': '-' + height + 'px'
    });
    $('#' + hintId).width(width);
    $('#' + hintId).height(height);
}
/* 隐藏图表无数据提示 */
/* $chart：图表所在的jquery dom对象 */
function chartNoDataHintHide($chart) {
    var hintId = $chart.attr('id') + '_hint';
    if($('#' + hintId).length > 0){
        $('#' + hintId).remove();
    }
}

/*解决因图表由隐藏到显示导致的无宽度无位置问题；在图表resize后调用*/
/* $chart：图表所在的jquery dom对象 */
function chartNoDataHintResize($chart) {
    let hintId = $chart.attr('id') + '_hint';
    //判断是否已添加提示dom
    if($('#' + hintId).length > 0){//已添加
        //获取dom的高宽
        var width = $chart.outerWidth();
        var height = $chart.outerHeight();
        $('#' + hintId).css({
            'marginTop': '-' + height + 'px'
        });
        $('#' + hintId).width(width);
        $('#' + hintId).height(height);
    }
}

/*弱提示modal事件*/
//参数说明：content：提示文字内容；iconstyle：图标类型：success-成功(默认)，fail-失败，none-无图标；callback：回调函数
function showModalHint(iconstyle, content, callback) {
    $('.modal-hint').remove();//移除其他弱提示项，避免并发
    var image = '<img src="../customize/images/icon/icon-check.png" />';
    if (iconstyle == 'fail') {
        image = '<img src="../customize/images/icon/icon-error.png" />';
    }
    if (iconstyle == 'none') {
        image = '';
    }
    var modal_hint = '<div class="modal-hint">' + image + ' ' + content + '</div>';
    $('body').append($(modal_hint));
    //位置调整
    var w = $('.modal-hint').outerWidth();
    w = w / 2 * (-1);
    $('.modal-hint').css({ 'marginLeft': w + 'px' });
    setTimeout(function () {
        $('.modal-hint').remove();
        if (callback) {
            callback();
        }
    }, 1500);
}

/*弱提示-显示loading*/
function showLoading(content) {
    $('.modal-hint').remove();//移除其他弱提示项，避免并发
    var image = '<img class="rotate" src="../customize/images/icon/icon-loading2.png" />';
    if (!content) {
        content = 'Loading';
    }
    var modal_hint = '<div class="modal-hint">' + image + ' ' + content + '</div>';
    $('body').append($(modal_hint));
    //位置调整
    var w = $('.modal-hint').outerWidth();
    w = w / 2 * (-1);
    $('.modal-hint').css({ 'marginLeft': w + 'px' });
}

/*弱提示-隐藏loading*/
function hideLoading() {
    $('.modal-hint').remove();
}

/*强提示-含遮罩层-显示loading*/
function showImpLoading(content) {
    $('.modal-hint').remove();//移除其他弱提示项，避免并发
    var image = '<img class="rotate" src="../customize/images/icon/icon-loading2.png" />';
    if (!content) {
        content = 'Loading';
    }
    var modal_hint = '<div class="modal-hint strong">' + image + ' ' + content + '</div>';
    $('body').append($(modal_hint));
}